package user;

import book.BookList;
import opertion.*;

import java.util.Scanner;
//管理员
public class AdmiUser extends User{
    public AdmiUser(String name) {
        super(name);
        this.iOperations=new IOperation[]{
                new ExitOpertion(),//退出程序
                new FindOpertion(),//查找
                new AddOpertion(),//增添
                new DeletOpertion(),//删除
                new ShowOpertion()//显示
        };
    }

    public void doOpertion(int choice, BookList bookList){
        this.iOperations[choice].work(bookList);
    }
    public  int menu(){
        int choice = -1;
        while(true) {
            System.out.println("欢迎 " + this.name + " 来到图书管理系统");
            System.out.println("--------管理员菜单------------");
            System.out.println("1.查找图书");
            System.out.println("2.新增图书");
            System.out.println("3.删除图书");
            System.out.println("4.显示图书");
            System.out.println("0.退出系统");
            System.out.println("-----------------------------");
            System.out.println("请输入您的操作");
            Scanner scanner = new Scanner(System.in);
            choice = scanner.nextInt();
            if(choice >=0 && choice <= 4){
                break;
            }else {
                System.out.println("输入错误");
            }
        }
        return choice;
    }
}
